home *** CD-ROM | disk | FTP | other *** search
Text File | 1993-05-14 | 4.7 KB | 184 lines | [TEXT/YERK] |
- \ qd1 - more QuickDraw objects
- \ 12/14/84 cbd Version 1
- \ 11/16/85 cdn Added disp: method to Picture & Icon
- \ 8/31/88 rfl added theClip to this source
- \ 8/14/90 rfl moveto fixed
- \ 4/11/92 rfl added putResId: as alias for init:
- \ 5/13/94 rfl protected getnew:'s
- Decimal
-
- rect theClip \ global clip rectangle
- -1000 dup 1000 dup put: theClip
-
- : +pair { x1 y1 x2 y2 -- x1+y1 x2+y2 } x1 x2 + y1 y2 + ;
-
- \ Interface object for QD picture support
- :CLASS Picture <Super Object
-
- Handle picHndl
- Int resID \ resource ID if it is a resource
- Rect DestRect \ destination rectangle for drawing
-
- \ ( l t r b -- ) Open a new pict with given frame
- :M OPEN: Put: destrect 0 abs: destrect call OpenPicture
- Put: picHndl ;M
-
- \ ( -- ) terminate this picture definition
- :M CLOSE: call ClosePicture ;M
-
- \ ( resID -- )
- :M INIT: put: resID ;M
-
- :M PUTRESID: put: resID ;M
-
- \ load the picture from a resource file
- :M GETNEW: 0 int: resID call GetPicture dup 0= classerr" 170 put: picHndl
- ptr: picHndl 2+ get: rect put: destRect ;M
-
- \ ( w h -- ) Set size in pixels of dest rect
- :M SIZE: getTop: destRect +Pair putBot: destRect ;M
-
- \ ( x y -- ) Move dest rect to given location
- :M GOTO: { x y -- } Size: destRect x y putTop: DestRect
- Size: self ;M
-
- \ ( -- ) Draw the picture in destRect
- :M DRAW: get: picHndl abs: destRect
- call DrawPicture ;M
-
- \ ( x y resID -- ) Combines the actions of init:, getNew:, goto: & draw:
- :M DISP: putResID: self getNew: self goto: self draw: self ;M
-
- \ goto to location and draw self
- :M MOVETO: ( x y -- ) goto: self draw: self ;M
-
- \ ( -- ) dispose of picture heap
- :M KILL: get: picHndl call KillPicture ;M
-
- ;CLASS
-
- \ resource-based Icon
-
- :CLASS Icon <Super Object
-
- Handle theHandle
- Int resID
- Rect theRect
-
- \ ( resID -- ) set the resource ID
- :M INIT: put: resID ;M
-
- \ load the icon from a resource file
- :M GETNEW: 0 int: resID call GetIcon dup 0= classerr" 170 put: theHandle ;M
-
- \ ( x y -- ) move topLeft corner to x,y
- :M GOTO: { x y -- } x y x 32 + y 32 + put: theRect ;M
-
- \ draw the icon at current location
- :M DRAW: abs: theRect get: theHandle call PlotIcon ;M
-
- \ ( x y resID -- ) Combines the actions of init:, getNew:, goto: & draw:
- :M DISP: init: self getNew: self goto: self draw: self ;M
-
- ;CLASS
-
- \ define the quickDraw bitmap object
- :CLASS qdBitMap <Super Object
-
- Var BaseAddr
- Int RowBytes
- Rect BndsRect
-
- \ ( addr n l t r b -- )
- :M PUT: Put: bndsRect Put: RowBytes
- Put: BaseAddr ;M
-
- ;CLASS
-
- \ rounded rectangle
- :CLASS RndRect <Super Rect
-
- Point ovalSize \ size in pixels of ovals at corners
-
- \ ( w h -- ) set width, height of corners
- :M INIT: put: ovalSize ;M
-
- \ ( -- )
- :M DRAW: (abs) int: ovalSize call FrameRoundRect ;M
-
- :M PRINT: Draw: Self ;M
-
- :M CLEAR: (abs) int: ovalSIze call EraseRoundRect ;M
-
- \ ( ^patObj -- ) Fill rect with pattern )
- :M FILL: { pat -- }
- (abs) int: ovalSize pat +base call FillRoundRect ;M
-
- \ ( -- x y )
- :M CENTER: { \ x y -- } Size: Self 2/ -> y 2/ -> x
- GetX: TopL x + getY: topL y + ;M
-
- \ ( -- )
- :M INVERT: (abs) int: ovalSize call InverRoundRect ;M
-
- \ ( -- )
- :M PAINT: (abs) int: ovalSize call PaintRoundRect ;M
-
- ;CLASS
-
- \ QuickDraw ovals - data is same as a Rect
- :CLASS Oval <Super Rect
-
- \ ( -- )
- :M DRAW: (abs) call FrameOval ;M
-
- \ ( -- )
- :M CLEAR: (abs) call EraseOval ;M
-
- \ ( -- )
- :M PAINT: (abs) call PaintOval ;M
-
- :M FILL: { pat -- } (abs) pat +base call FillOval ;M
-
- :M INVERT: (abs) call InvertOval ;M
-
- ;CLASS
-
- \ Variable-length image object for bit images
- \ E.G., an Icon would have 32 cells, rowbytes=4
- :CLASS Image <Super Array
-
- Var BaseAddr
- Int RowBytes \ Source bitMap
- Rect bndsRect
- Var DestBits \ addr of destination bit image
- Int Mode
- Rect Destrect \ Destination rect for CopyBits
-
- \ ( -- ) Set the source, destination bitmap ptrs
- :M GETPORT: Abs: DestBits call GetPort 2 +: DestBits
- 0 ^elem: self +base Put: baseAddr ;M
-
- \ ( mode rowBytes topX topY -- )
- :M INIT: { themode rBytes topX topY -- } themode Put: mode
- rBytes Put: RowBytes topX topY PutTop: bndsRect
- rBytes 8 * topX + \ # of bits in a row + topX
- limit: self width: self * rBytes / topY + \ # of rows + topy
- PutBot: bndsRect
- GetPort: Self ;M
-
- \ ( x y -- ) Move location without drawing
- :M GOTO: { xloc yloc -- } xloc yloc Puttop: DestRect
- size: bndsRect xloc yloc +Pair PutBot: destRect ;M
-
- \ ( -- ) Draw the image at its current location
- :M DRAW: (abs) Get: DestBits Abs: bndsRect Abs: DestRect
- Int: Mode 0 call CopyBits ;M
-
- \ ( x y -- ) Goto a location and draw the image
- :M MOVETO: Goto: Self Draw: Self ;M
-
- :M CLASSINIT: srcXor 2 0 0 Init: Self 0 0 Goto: self ;M
-
- ;CLASS
-